<?php 
session_start(); // on relaye la session 
if(isset($_SESSION["is_registered"]) && $_SESSION["is_registered"] == "registered"){
		$enregistrer = $_SESSION["is_registered"];
}else{
	header("location:../../../menu.php"); // redirection en cas d'echec
}
require_once('../../../Connections/microassur.php'); 
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$colname_rs_eltdico = "-1";
if (isset($_GET['Identifiant_element'])) {
  $colname_rs_eltdico = $_GET['Identifiant_element'];
}
mysql_select_db($database_microassur, $microassur);
$query_rs_eltdico = sprintf("SELECT * FROM elementdico WHERE Identifiant_element = %s", GetSQLValueString($colname_rs_eltdico, "int"));
$rs_eltdico = mysql_query($query_rs_eltdico, $microassur) or die(mysql_error());
$row_rs_eltdico = mysql_fetch_assoc($rs_eltdico);
$totalRows_rs_eltdico = mysql_num_rows($rs_eltdico);

if ((isset($_GET['Identifiant_element'])) && ($_GET['Identifiant_element'] != "")) {
  $deleteSQL = sprintf("DELETE FROM elementdico WHERE Identifiant_element=%s",
					   GetSQLValueString($_GET['Identifiant_element'], "int"));

  mysql_select_db($database_microassur, $microassur);
  mysql_query("START TRANSACTION");
  $Result1 = mysql_query($deleteSQL, $microassur) or die(mysql_error());
	  if($Result1){mysql_query("commit");$deleteGoTo = "modelementdico.php?msg=supp";}
	  else {mysql_query("rollback");$deleteGoTo = "modelementdico.php?msg=err_supp";}
}

if (isset($_SERVER['QUERY_STRING'])) {
	$deleteGoTo .= (strpos($deleteGoTo, '?')) ? "" : "";/* & ? */
	/* $deleteGoTo .= $_SERVER['QUERY_STRING']; */
}
header(sprintf("Location: %s", $deleteGoTo));

?>